import datetime
import argparse


def add_log(text):
    current_time = get_current_time()
    print(f"{current_time}: {text}")


def get_start_date():
    return get_args().start


def get_end_date():
    return get_args().end


def get_args():
    parser = argparse.ArgumentParser(description='Process some integers.')
    parser.add_argument('-start', type=str, help='an optional integer argument')
    parser.add_argument('-end', type=str, help='an optional integer argument')
    args = parser.parse_args()
    return args


def get_current_time():
    current_time = datetime.datetime.now()
    return current_time.strftime("%Y-%m-%d %H:%M:%S")


def check_is_same_day(start_time, end_time):
    return start_time[:10] == end_time[:10]


def get_full_range_date(start_time, end_time):
    start = datetime.datetime.strptime(start_time, '%Y-%m-%d')
    end = datetime.datetime.strptime(end_time, '%Y-%m-%d %H:%M:%S')
    date_list = []
    while (start < end):
        date = start.strftime('%Y-%m-%d')
        date_list.append(date)
        start = start + datetime.timedelta(days=1)
    return date_list


def get_value_by_map(map, key, default=0):
    arr = key.split(".")
    for a in arr:
        val = map.get(a)
        if val is None:
            return default
        else:
            map = val
    return val
